<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/layouts/include/taglib.jsp" %>

<!-- 任务修改 -->
         <div class="modal" id="selectToMember" style="">
             <div class="modal-dialog">
                 <div class="modal-content">
                    <div class="modal-header ">
                         <button type="button" id="closeSelectMember" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <span>选择人员</span>
                     </div>
                     <div class="modal-body ">
                    	<div class="row">
						<div class="col-sm-5" >
			<div class="widget-box">
				<div class="widget-header header-color-grey">
					<h4 class="lighter smaller">项目角色</h4>
					
				</div>
				<div class="widget-body">
					<div class="widget-main padding-0">
						<form class="form-horizontal" role="form" name="codeDictSaveForm"
							id="codeDictSaveForm"
							data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
							data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
							data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
							<table id="dictTable" class="table table-striped  table-hover">
								<thead>
									<tr>
										<th></th>
										<th>角色</th>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="col-sm-7">
			<div class="widget-box" id="detailView">
				<div class="widget-header header-color-grey">
					<h4 class="lighter smaller">人员</h4>
				</div>

				<div class="widget-body">
					<div class="widget-main padding-8">
						<div id="task-tab" class="tab-pane active">
							<h4 class="smaller lighter green">
								<i class="icon-list"></i> <span id="codeInfoTitle">人员选择</span>
								<button type="button" class="btn pull-right btn-sm btn-info" id="submitSelect">
									提交							
									<i class="icon-ok icon-on-right bigger-110"></i>
								</button>
							</h4>

							<ul id="codeInfoList" class="item-list">

							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
</div>
					
                         
                     </div>
                     <!-- <div class="modal-footer">
                     	
                     </div> -->
                 </div>
                 <!-- /.modal-content -->
             </div>
             <!-- /.modal-dialog -->
         </div>
         <!-- /.modal -->
         
 <script>
var datatable;


//查询参数项列表
function searchCodeInfo(roleNo,dictName){
	//当点击类别的时候把dictNo设置到隐藏域中
	if(dictName){
		$("#codeInfoTitle").text(dictName);
	}
	$("#codeInfoId").val(roleNo);
	$("#detailView").show();
	//把修改隐藏
	//
	Otod.ajax({
		url:"${ctx}/pm/team/findByPrjIdAndRoleNo.do?prjId="+prjId, //+"&roleNo="+roleNo,
		//data: {prjId:prjId,roleNo:roleNo},
		successFn: function(data){
			var sb = new StringBuffer();
			var temp;
			$.each(data, function(i, n){
				sb.append('<li class="');
				temp = (i+1) % 4;							//循环4种颜色
				switch(temp){
					case 1: sb.append('item-orange'); break;
					case 2: sb.append('item-red'); break;
					case 3: sb.append('item-blue'); break;
					default:sb.append('item-default');
				}
				
				sb.append(' clearfix" liId="').append(n.uuid).append('">');
				sb.append('		<label class="inline">');
				sb.append('			<span class="lbl">');
				sb.append('【').append(n.roleName).append('】').append(n.empName);
				sb.append('			</span>');
				sb.append('		</label>');

				sb.append('		<div class="pull-right action-buttons">');
				sb.append('			<input role="checkbox" type="checkbox" class="cbox" id="').append(n.empNo).append('" >');
				sb.append('		</div>');
				sb.append('</li>');
			});
			$("#codeInfoList").html(sb.toString());
		}
	 });
}

$(document).ready(function() {
	//把参数列表宽隐藏
	//详细信息框隐藏
	$("#detailView").hide();
	$('#codeDictSaveForm').bootstrapValidator();
		//定义列
		var dictTableColums = [
	            {
					"mData":"uuid",
					"sClass": "center",
					"bSortable": false,
					"mRender" : function(data, type, row) {
						return '<a no="'+row.codeNo+'" name="'+row.codeName+'"  href="#"></a>';
					}
	            },
	           // {"mData":"codeNo"},
	            {"mData": "codeName"}
	    ];
		
		 //初始化dataTable
		datatable = $('#dictTable').dataTable( {
	    	'sAjaxSource': '${ctx}/sys/code/queryByPmPrjRole.do',	//请求数据源 
	    	"fnServerData": function(sSource, aoData, fnCallback,oSettings){
	    		//$.extend(aoData,$('#dictQueryForm').serializeArray());
	    		$.ajax({
		    		dataType: 'json',
		    		url : sSource,
		    		data: aoData,
		    		success: fnCallback
	    		});
	    	},
	    	//"sServerMethod":"post",  
			'bServerSide':true,							//是否启动服务器端数据导入
			"bLengthChange" : false,
			"bInfo" : true,
			"bPaginate" : true,
	        'bFilter': false,                       	//是否使用内置的过滤功能。
	        'aoColumns': dictTableColums,
	        "sDom": '<"toolbar">frtip', 
	        "oLanguage": oLanguage
		});
	    

	    //设置列表选中效果
		$("#dictTable tbody").on('click','tr',function(e) {
		        if ( $(this).hasClass('row_selected') ) {
		            //$(this).removeClass('row_selected');
		        }else{
		        	datatable.$('tr.row_selected').removeClass('row_selected');
		            $(this).addClass('row_selected');
		            var aEl = $(this).find("td a:first");
		            searchCodeInfo(aEl.attr("no"),aEl.attr("name"));
		            //aEl.attr("no")  得到具体的id
		        }
		 });
	    
	    $("#submitSelect").on('click',function(e){
	    	var fileId = prjId;
	    		var arry = new Array();
    		if($("#codeInfoList .cbox:checked").length<=0){
    			Otod.Msg.info("未选择提交对象！");
    			return;
    		}
	    	$.each($("#codeInfoList .cbox:checked"),function(i,n){
	    		arry.push(n.id);
	    	});
	    	var empNo = arry.join(";");
	    	
	    	
	    	Otod.ajax({
	    		url:"${ctx}/pm/comment/submitAudit.do",
	    		data: {prjId:prjId,submitEmpNo:empNo,fileId:fileId},
	    		type:'GET',
	    		successFn: function(data){
	    				
		    			$("#closeSelectMember").click();
		    			Otod.Msg.info(data.info);
	    			
	    		}
	    	 }); 
	    });
	});
</script>
 

